import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:liuxlcommon/util/MyNumberTextInputFormatter.dart';
import 'package:liuxlcommon/view/loading_view.dart';
import 'package:liuxlcommon/view/my_style.dart';

double uiSizeWidth = 375;

double get scaleWidth => screenWidth / uiSizeWidth;
double screenWidth = 0;
late BuildContext _context;

LWidgetInit(BuildContext context, [double _uiSizeWidth = 375]) {
  _context = context;
  uiSizeWidth = _uiSizeWidth;
  screenWidth = MediaQuery.of(_context).size.width;
}

class OldLContainer extends StatelessWidget with comm {
  GestureTapCallback? onTap;
  Widget? body;
  LStyle lStyle;

  OldLContainer({super.key, this.onTap, required this.lStyle, Widget? child}) {
    body = getLContainer(child, lStyle, onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text("data");
  }
}

extension LColumnExtension on List<Widget> {
  LFlexV get column => LFlexV(this);

  get columnExpand => LExpand(child: LColumn(lStyle: LStyle(), children: this));

  get columnSlid => SingleChildScrollView(child: Column(children: this));

  get columnSlidExpand =>
      LExpand(child: SingleChildScrollView(child: Column(children: this)));

  setColumnSlidExpand({lStyle}) => LExpand(
      child: SingleChildScrollView(
          child: LColumn(lStyle: lStyle ?? LStyle(), children: this)));

  setColumn([LStyle? lStyle, onTap]) =>
      LColumn(lStyle: lStyle ?? LStyle(), children: this, onTap: onTap);

  setColumnSlid([LStyle? lStyle, onTap]) => SingleChildScrollView(
        child:
            LColumn(lStyle: lStyle ?? LStyle(), children: this, onTap: onTap),
      );
}

class LColumn extends StatelessWidget with comm {
  List<Widget> children;

  GestureTapCallback? onTap;
  Widget? body;
  LStyle lStyle;

  static LFlexV eazy(List<Widget> list, [color, radius]) {
    return LFlexV(list).style(LStyle()
      ..color = color
      ..radius = radius);
  }

  LColumn(
      {super.key, this.onTap, required this.lStyle, required this.children}) {
    if ((lStyle.spaceBetween ?? 0) > 0) {
      for (int i = children.length - 1; i >= 1; i--) {
        children.insert(
            i,
            SizedBox(
              height: lStyle.spaceBetween,
            ));
      }
    }

    body = getLContainer(
        Column(
          crossAxisAlignment:
              lStyle.crossAxisAlignment ?? CrossAxisAlignment.center,
          mainAxisAlignment:
              lStyle.mainAxisAlignment ?? MainAxisAlignment.start,
          mainAxisSize: lStyle.mainAxisSize ?? MainAxisSize.min,
          children: children,
        ),
        lStyle,
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text("data");
  }
}

extension LRowExtension on List<Widget> {
  LFlexH get row => LFlexH(this);
}

class LRow extends StatelessWidget with comm {
  List<Widget> children;

  GestureTapCallback? onTap;
  LStyle lStyle;
  Widget? body;

  static LFlexH eazy(List<Widget> list, [color, radius]) {
    return LFlexH(list).style(LStyle()
      ..color = color
      ..radius = radius);
  }

  LRow({this.onTap, required this.lStyle, required this.children, super.key}) {
    if ((lStyle.spaceBetween ?? 0) > 0) {
      for (int i = children.length - 1; i > 0; i--) {
        children.insert(
            i,
            SizedBox(
              width: lStyle.spaceBetween,
            ));
      }
    }

    body = getLContainer(
        Row(
          crossAxisAlignment:
              lStyle.crossAxisAlignment ?? CrossAxisAlignment.center,
          mainAxisAlignment:
              lStyle.mainAxisAlignment ?? MainAxisAlignment.start,
          mainAxisSize: lStyle.mainAxisSize ?? MainAxisSize.min,
          children: children,
        ),
        lStyle,
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

class LExpand extends StatelessWidget with comm {
  Widget? child;

  GestureTapCallback? onTap;
  LStyle? lStyle;
  Widget? body;

  LExpand({int? flex, this.child}) {
    body = Expanded(
      flex: flex ?? 1,
      child: child ?? const SizedBox(),
    );
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

class LSizeW extends StatelessWidget with comm {
  Widget? child;

  GestureTapCallback? onTap;
  LStyle? lStyle;
  Widget? body;
  double width;

  LSizeW(this.width,
      {super.key, this.child, this.onTap, this.lStyle, int? flex}) {
    var stl = lStyle ?? LStyle();

    body = getLContainer(
        SizedBox(
          width: width,
          child: child,
        ),
        stl,
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

class LSizeBoxWidth extends StatelessWidget with comm {
  Widget? child;

  GestureTapCallback? onTap;
  LStyle? lStyle;
  Widget? body;
  double width;

  LSizeBoxWidth(this.width,
      {super.key, this.child, this.onTap, this.lStyle, int? flex}) {
    var stl = lStyle ?? LStyle();

    body = getLContainer(
        SizedBox(
          width: width,
          child: child,
        ),
        stl,
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

extension LSizeExtension on num {
  Widget get lsh => LSizeBoxHeight(scaleWidth * this.toDouble());

  Widget get lsw => LSizeBoxWidth(scaleWidth * this.toDouble());
}

class LSizeBoxHeight extends StatelessWidget with comm {
  Widget? child;

  GestureTapCallback? onTap;
  LStyle? lStyle;
  Widget? body;
  double height;

  LSizeBoxHeight(this.height, {this.child, this.onTap, this.lStyle}) {
    body = getLContainer(
        SizedBox(
          child: child,
          height: height,
        ),
        lStyle ?? LStyle(),
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

class LSizeH extends StatelessWidget with comm {
  Widget? child;

  GestureTapCallback? onTap;
  LStyle? lStyle;
  Widget? body;
  double height;

  LSizeH(this.height, {this.child, this.onTap, this.lStyle}) {
    body = getLContainer(
        SizedBox(
          child: child,
          height: height,
        ),
        lStyle ?? LStyle(),
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

class OldLText extends StatelessWidget with comm {
  GestureTapCallback? onTap;
  Widget? body;

  static OldLText easy(dynamic str,
          [double? fontSize, fontWeight, Color? color, int? flex]) =>
      OldLText(
        str,
        lStyle: LStyle(
            flex: flex,
            fontSize: fontSize,
            fontWeight: fontWeight ?? FontWeight.w400,
            color: color),
      );

  OldLText(dynamic str, {required LStyle lStyle, this.onTap}) {
    str ??= "";
    if (str is int || str is double) str = str.toString();
    var text = Text(str,
        style: TextStyle(
            fontSize: lStyle.fontSize ?? 14,
            fontWeight: lStyle.fontWeight,
            color: lStyle.color),
        textAlign: lStyle.textAlign ?? TextAlign.start,
        overflow: lStyle.maxLines != null ? TextOverflow.ellipsis : null,
        maxLines: lStyle.maxLines);
    body = getLContainer(
        lStyle.textGradient != null
            ? ShaderMask(
                shaderCallback: (bounds) =>
                    lStyle.textGradient!.createShader(bounds),
                child: text)
            : text,
        lStyle,
        onTap: onTap);
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

enum LInputType { TEXT, INT, DOUBLE, DOUBLETO2, PASSWORD }

class OldLInput extends StatefulWidget {
  LStyle lStyle;
  Widget? body;
  FocusNode? focusNode;
  static FocusNode defFocusNode = FocusNode();
  String str;
  LInputType lInputType;
  Function(String text)? onChanged;
  Function(String text)? onSubmitted;

  static List<FocusNode> focusNodeList = [];

  static FocusNode getFocusNode() {
    var f = FocusNode();
    focusNodeList.add(f);
    return f;
  }

  static unfocus() {
    for (var f in focusNodeList) {
      if (f.hasFocus) {
        f.unfocus();
      }
    }
  }

  static addFocusNode(FocusNode f) {
    if (!focusNodeList.contains(f)) {
      focusNodeList.add(f);
    }
  }

  static removeFocusNode(FocusNode f) {
    focusNodeList.remove(f);
  }

  OldLInput(this.str,
      {super.key,
      this.onChanged,
      this.onSubmitted,
      required this.lStyle,
      this.focusNode,
      this.lInputType = LInputType.TEXT});

  static OldLInput easy(String str,
          [double? fontSize,
          fontWeight = FontWeight.w400,
          Color? color,
          int? flex]) =>
      OldLInput(
        str,
        lStyle: LStyle(flex: flex, fontSize: fontSize, fontWeight: fontWeight),
      );

  @override
  State<StatefulWidget> createState() => _LInput(str,
      lStyle: lStyle,
      lInputType: lInputType,
      onChanged: onChanged,
      onSubmitted: onSubmitted,
      focusNode: focusNode);
}

class _LInput extends State<OldLInput> with comm {
  LStyle lStyle;
  Widget? body;
  FocusNode? focusNode;
  TextEditingController editingController = TextEditingController();

  @override
  void dispose() {
    super.dispose();
    if (focusNode != null) OldLInput.removeFocusNode(focusNode!);
  }

  _LInput(str,
      {required this.lStyle,
      void Function(String text)? onChanged,
      void Function(String text)? onSubmitted,
      focusNode,
      LInputType lInputType = LInputType.TEXT}) {
    if (focusNode == null) {
      focusNode = OldLInput.getFocusNode();
      this.focusNode = focusNode;
    } else {
      OldLInput.addFocusNode(focusNode);
    }
    TextInputType inputType = TextInputType.text;
    List<TextInputFormatter> inputFormatters = [];
    switch (lInputType) {
      case LInputType.TEXT:
        break;
      case LInputType.INT:
      case LInputType.PASSWORD:
        inputType = TextInputType.phone;
        inputFormatters.add(FilteringTextInputFormatter.digitsOnly);
        break;
      case LInputType.DOUBLE:
        inputType = const TextInputType.numberWithOptions(decimal: true);
        break;
      case LInputType.DOUBLETO2:
        inputType = const TextInputType.numberWithOptions(decimal: true);
        inputFormatters.add(MyNumberTextInputFormatter(digit: 2));
        break;
    }
    if (lStyle.maxLength != null) {
      inputFormatters.add(LengthLimitingTextInputFormatter(lStyle.maxLength));
    }
    if (lStyle.editingController != null)
      editingController = lStyle.editingController!;
    editingController.text = str;
    body = getLContainer(
        TextField(
          key: lStyle.key,
          onTap: lStyle.onTap,
          focusNode: focusNode,
          obscureText: lStyle.obscureText ?? false,
          controller: editingController,
          textAlign: lStyle.textAlign ?? TextAlign.start,
          keyboardType: inputType,
          textInputAction: TextInputAction.done,
          maxLines: lStyle.maxLines,
          readOnly: lStyle.readOnly ?? false,
          maxLength: lStyle.showMaxLengthTxt ? lStyle.maxLength : null,
          style: TextStyle(
              color: lStyle.color,
              fontSize: lStyle.fontSize,
              fontWeight: lStyle.fontWeight),
          decoration: InputDecoration(
              isCollapsed: true,
              // contentPadding: (lStyle.height ?? 100) < 50
              //     ? EdgeInsets.only(top: (lStyle.height ?? 0) / 5)
              //     : null,
              //内容内边距，影响高度,
              border: InputBorder.none,
              hintText: lStyle.hintText ?? "",

              hintStyle: TextStyle(color: lStyle.hintColor)),
          onChanged: (txt) {
            onChanged!(txt);
          },
          onSubmitted: (t) {
            Future.delayed(Duration(milliseconds: 100), () {
              focusNode.unfocus();
            });
            if (onSubmitted != null) onSubmitted(t);
          },
          inputFormatters: inputFormatters,
        ),
        lStyle, onTap: () {
      focusNode.requestFocus();
    });
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }

  @override
  void didUpdateWidget(covariant OldLInput oldWidget) {
    super.didUpdateWidget(oldWidget);
    if (editingController.text != widget.str) {
      editingController.text = widget.str;
      // TextEditingValue currentValue = editingController.value;
      // TextEditingValue updatedValue = currentValue.copyWith(
      //   text: currentValue.text,
      //   selection: currentValue.selection,
      //   composing: currentValue.composing,
      //   hintText: lStyle.hintText,
      // );
      // controller.value = updatedValue;
    }
  }
}

class LDivider extends StatelessWidget with comm {
  GestureTapCallback? onTap;
  Widget? body;

  LDivider([double height = 1, Color? color, int? flex]) {
    body = Divider(
      height: height,
      color: color,
    );
  }

  @override
  Widget build(BuildContext context) {
    return body ?? const Text(":");
  }
}

mixin comm {
  Widget getLContainer(body, LStyle lStyle, {onTap}) {
    if ((lStyle.radius ?? 0) > 0 ||
        lStyle.color != null ||
        lStyle.backgroundImage != null ||
        lStyle.backgroundColor != null ||
        lStyle.decoration != null ||
        lStyle.border != null ||
        lStyle.borderWidth != null ||
        lStyle.borderRadius != null ||
        lStyle.width != null ||
        lStyle.height != null ||
        lStyle.alignment != null ||
        lStyle.padding != null ||
        lStyle.boxShadow != null ||
        lStyle.gradient != null ||
        lStyle.onTapDown != null ||
        lStyle.margin != null) {
      var border = lStyle.border;
      var borderRadius =
          lStyle.radius == 0 ? null : BorderRadius.circular(lStyle.radius ?? 0);
      if (lStyle.borderWidth != null) {
        border = Border.all(
            color: lStyle.borderColor ?? Colors.black,
            width: lStyle.borderWidth!);
      }
      if (lStyle.borderRadius != null) {
        borderRadius = lStyle.borderRadius;
      }

      body = Container(
        width: lStyle.width,
        height: lStyle.height,
        child: body,
        padding: lStyle.padding,
        margin: lStyle.margin,
        alignment: lStyle.alignment,
        decoration: lStyle.decoration ??
            BoxDecoration(
                color: lStyle.backgroundColor,
                border: border,
                gradient: lStyle.gradient,
                borderRadius: borderRadius,
                boxShadow: lStyle.boxShadow,
                image: lStyle.backgroundImage == null
                    ? null
                    : DecorationImage(
                        centerSlice: lStyle.centerSlice,
                        image: AssetImage(lStyle.backgroundImage!),
                        fit: BoxFit.fill)),
      );
    }
    if (onTap != null) {
      body = InkWell(
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
        onTap: onTap,
        child: body,
      );
    }

    if (lStyle.onTapDown != null) {
      body = GestureDetector(
        onTapDown: lStyle.onTapDown,
        child: body,
      );
    }

    if (lStyle.isScroll ?? false) {
      body = SingleChildScrollView(child: body);
    }
    if (lStyle.flex != null) {
      body = Expanded(child: body, flex: lStyle.flex!);
    }
    return body;
  }
}

class LStack extends StatelessWidget with LWComm {
  List<Widget> children;

  LStack(this.children, {super.key});

  @override
  Widget build(BuildContext context) => LContainer(
      lStyle: lStyle,
      child: Stack(
        children: children,
      ),
      onTap: lStyle.onTap);
}

///new
class LFlexV extends StatelessWidget with LWComm {
  List<Widget> children;

  LFlexV(this.children, {super.key});

  @override
  Widget build(BuildContext context) {
    return LColumn(
      lStyle: lStyle,
      children: children,
      onTap: lStyle.onTap,
    );
  }
}

class LFlexH extends StatelessWidget with LWComm {
  List<Widget> children;

  LFlexH(this.children, {super.key});

  @override
  Widget build(BuildContext context) {
    return LRow(lStyle: lStyle, children: children, onTap: lStyle.onTap);
  }
}

class LText extends StatelessWidget with LWComm {
  dynamic? text;

  static LText e(dynamic str,
          [double? fontSize, fontWeight, Color? color, int? flex]) =>
      easy(str, fontSize, fontWeight, color, flex);

  static LText easy(dynamic str,
          [double? fontSize, fontWeight, Color? color, int? flex]) =>
      LText(
        str,
        lStyle: LStyle(
            flex: flex,
            fontSize: fontSize,
            fontWeight: fontWeight ?? FontWeight.w400,
            color: color),
      );

  LText(this.text, {LStyle? lStyle, super.key, GestureTapCallback? onTap}) {
    if (lStyle != null) {
      this.lStyle = lStyle;
    }
    if (onTap != null) {
      this.lStyle.onTap = onTap;
    }
  }

  @override
  Widget build(BuildContext context) {
    return OldLText(text, lStyle: lStyle, onTap: lStyle.onTap);
  }
}

class LContainer extends StatelessWidget with LWComm {
  GestureTapCallback? onTap;
  Widget? child;

  LContainer({super.key, this.onTap, LStyle? lStyle, Widget? child}) {
    if (lStyle != null) {
      this.lStyle = lStyle;
    }
    this.child = child;
  }

  @override
  Widget build(BuildContext context) {
    return OldLContainer(lStyle: lStyle, onTap: onTap, child: child);
  }
}

class LInput extends StatelessWidget with LWComm {
  String str;
  String? hintStr;
  FocusNode? focusNode;
  static FocusNode defFocusNode = FocusNode();
  LInputType? lInputType;
  Function(String text)? onChanged;
  Function(String text)? onSubmitted;

  static LInput easy(String str,
          [String? hintStr,
          double? fontSize,
          fontWeight = FontWeight.w400,
          Color? color,
          int? flex]) =>
      LInput(str,
          lStyle: LStyle(
              flex: flex,
              fontSize: fontSize,
              fontWeight: fontWeight,
              hintText: hintStr));

  LInput(this.str,
      {this.onChanged,
      this.onSubmitted,
      LStyle? lStyle,
      this.focusNode,
      this.lInputType = LInputType.TEXT}) {
    if (lStyle != null) {
      this.lStyle = lStyle;
    }
    if (this.onChanged != null) {
      this.lStyle.onChange = onChanged;
    }
  }

  @override
  Widget build(BuildContext context) {
    return OldLInput(str,
        lStyle: lStyle,
        onChanged: lStyle.onChange,
        onSubmitted: onSubmitted,
        focusNode: focusNode,
        lInputType: lInputType ?? LInputType.TEXT);
  }
}

class LListView extends StatelessWidget with LWComm {
  dynamic Function() datas;
  Widget Function(int postion) itemView;
  Function(bool isUp) onRefresh;

  final GlobalKey<childLoadingView> _childWidgetKey = GlobalKey();

  LListView(
      {required this.datas, required this.itemView, required this.onRefresh});

  @override
  Widget build(BuildContext context) {
    return LContainer(
      child: LoadingView(
        key: _childWidgetKey,
        datas: datas(),
        itemCall: (context, position) => itemView(position),
        isPullUp: true,
        isPullDown: true,
        onLoad: (type) async {
          await onRefresh(type == 1);
          return datas();
        },
        onSuccess: () {
          if (datas() != null) {
            _childWidgetKey.currentState?.updateUI(datas: datas());
          }
        },
      ),
    ).style(lStyle);
  }
}

mixin LWComm {
  LStyle lStyle = LStyle();

  style(LStyle style) {
    lStyle = style;
    return this;
  }

  align(Alignment? align) {
    lStyle.alignment = align;
    lStyle.textAlign = TextAlign.center;
    if (align == Alignment.centerLeft || align == Alignment.topLeft) {
      lStyle.crossAxisAlignment = CrossAxisAlignment.start;
    } else if (align == Alignment.center) {
      lStyle.crossAxisAlignment = CrossAxisAlignment.center;
    } else if (align == Alignment.centerRight) {
      lStyle.crossAxisAlignment = CrossAxisAlignment.end;
    }
    return this;
  }

  /// -1 = double.infinity
  size(double? width, double? height) {
    if (width == -1) width = double.infinity;
    if (height == -1) height = double.infinity;
    lStyle.width = width;
    lStyle.height = height;
    return this;
  }

  /// -1 = double.infinity
  height(double height) {
    lStyle.height = height;
    return this;
  }

  width(double width) {
    lStyle.width = width;
    return this;
  }

  onTapDown(tap) {
    lStyle.onTapDown = tap;
    return this;
  }

  css(css) {
    lStyle.css = css;
    lStyle.cssConvert();
    return this;
  }

  bgColor(Color? color) {
    lStyle.backgroundColor = color;
    return this;
  }

  textGradient(List<Color> colors, Alignment end) {
    Alignment begin = end;
    if (end == Alignment.bottomCenter) {
      begin = Alignment.topCenter;
    } else if (end == Alignment.centerRight) {
      begin = Alignment.centerLeft;
    }
    lStyle.textGradient =
        LinearGradient(colors: colors, begin: begin, end: end);
    return this;
  }

  gradient(List<Color> colors, Alignment end) {
    Alignment begin = end;
    if (end == Alignment.bottomCenter) {
      begin = Alignment.topCenter;
    } else if (end == Alignment.centerRight) {
      begin = Alignment.centerLeft;
    }
    lStyle.gradient = LinearGradient(colors: colors, begin: begin, end: end);
    return this;
  }

  radius(double? radius) {
    lStyle.radius = radius;
    return this;
  }

  radiusOnly(
      {double? topLeft,
      double? topRight,
      double? bottomLeft,
      double? bottomRight}) {
    lStyle.borderRadius = BorderRadius.only(
        topLeft: Radius.circular(topLeft ?? 0),
        topRight: Radius.circular(topRight ?? 0),
        bottomLeft: Radius.circular(bottomLeft ?? 0),
        bottomRight: Radius.circular(bottomRight ?? 0));
    return this;
  }

  onTapL(tap) {
    lStyle.onTap = tap;
    return this;
  }

  marginAll(all) {
    lStyle.margin = EdgeInsets.fromLTRB(all ?? 0, all ?? 0, all ?? 0, all ?? 0);
    return this;
  }

  margin({double? left, double? top, double? right, double? bottom}) {
    lStyle.margin =
        EdgeInsets.fromLTRB(left ?? 0, top ?? 0, right ?? 0, bottom ?? 0);
    return this;
  }

  marginV(v) {
    lStyle.margin = EdgeInsets.symmetric(vertical: v);
    return this;
  }

  marginH(v) {
    lStyle.margin = EdgeInsets.symmetric(horizontal: v);
    return this;
  }

  ///居中。
  center() {
    lStyle.mainAxisAlignment = MainAxisAlignment.center;
    lStyle.alignment = Alignment.center;

    return this;
  }

  paddingAll(all) {
    lStyle.padding =
        EdgeInsets.fromLTRB(all ?? 0, all ?? 0, all ?? 0, all ?? 0);
    return this;
  }

  padding({left, top, right, bottom}) {
    lStyle.padding =
        EdgeInsets.fromLTRB(left ?? 0, top ?? 0, right ?? 0, bottom ?? 0);
    return this;
  }

  paddingV(v) {
    lStyle.padding = EdgeInsets.symmetric(vertical: v);
    return this;
  }

  paddingH(v) {
    lStyle.padding = EdgeInsets.symmetric(horizontal: v);
    return this;
  }

  flex(int? flex) {
    lStyle.flex = flex;
    return this;
  }

  bgImg(String? s) {
    lStyle.backgroundImage = s;
    return this;
  }

  textAlign(TextAlign? s) {
    lStyle.textAlign = s;
    return this;
  }

  border(double width, color) {
    lStyle.borderColor = color;
    lStyle.borderWidth = width;
    return this;
  }

  onChange(Function(String text)? onChanged) {
    lStyle.onChange = onChanged;
    return this;
  }

  maxLength(maxLength) {
    lStyle.maxLength = maxLength;
    return this;
  }

  maxLines(maxLines) {
    lStyle.maxLines = maxLines;
    return this;
  }

  scroll({isScroll = true}) {
    lStyle.isScroll = isScroll;
    return this;
  }

  boxShadow(List<BoxShadow> sh) {
    lStyle.boxShadow = sh;
    return this;
  }

  Widget asWidget() => this as Widget;
}
